<!DOCTYPE html>
<html lang="en">
<include file="Public/header" title="物品记录修改" keywords="社团管理系统，常州大学，课程设计" />

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">收支类型</label>
                            <div class="col-sm-10">
                                <div class="radio i-checks">
                                    <label>
                                        <input type="radio" value="1" name="expensemethod" >
                                    收入</label>
                                </div>
                                <div class="radio i-checks">
                                    <label>
                                        <input type="radio" value="2" name="expensemethod" >
                                    支出</label>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">金额</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="expensecharge" value="{$res['expensecharge']}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">时间</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="expensetime" value="{$res['expensetime']}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">笔记</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="expensenote" value="{$res['expensenote']}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <button type="button" class="btn btn-w-m btn-info" id="subbtn">确认提交</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>

<include file="Public/footer"/>
<script>
    $('#subbtn').on('click',function () {
        var btn = $(this);
        var expenseid = btn.data('id');
        var expensemethod = $("input[type='radio']:checked").val();
        var expensecharge = $('#expensecharge').val();
        var expensenote = $('#expensenote').val();
        var expensetime = $('#expensetime').val();
        var param = {
            expenseid:expenseid,
            expensemethod:expensemethod,
            expensecharge:expensecharge,
            expensenote:expensenote,
            expensetime:expensetime
        };
        console.log(param);
        if(!expensemethod || !expensecharge || !expensenote || !expensetime){
            alert('每一项都必须填写');
            return;
        }else{
            var url = "{:U('Expense/expensemodify')}";
            $.ajax({
                url: url,
                data: param,
                dataType: 'json',
                type: 'post',
                success: function (data) {
                    alert(data.info);
                    if (data.status == 1) {
                        window.location.href= "{:U('Expense/departexpense')}"
                    }
                },
                error: function () {
                    alert('操作失败');
                }
            })
        }

    })
</script>
</html>